<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <script src="<%=request.getContextPath()%>/js2/jquery.js"></script>
    <script src="<%=request.getContextPath()%>/js2/jquery.validate.min.js"></script>
    <script src="<%=request.getContextPath()%>/js2/messages_zh.js"></script>
    <script>
        function myFunction(){
            $.ajax({
                url:"<%=basePath%>/select",
                type:"post",
                success:function(data){
                    alert("******");
                    $("#myTable tbody").empty();
                    alert(data);
                    $.each(data,function(index,item){
                        var username=$("<td></td>").append(item.username);
                        var password=$("<td></td>").append(item.password);
                        var but=$("<button></button>").append($("<span></span>").append("编辑"));
                        var btn=$("<td></td>").append(but);
                        $("<tr></tr>").append(username).append(password).append(btn).appendTo("#myTable tbody");
                    })
                }
            });
        };
    </script>
</head>
<body>
<input type="button" value="获取" onclick="myFunction()"/>
<br>
   <table id="myTable">
       <thead>
            <tr>
               <td>用户名</td>
               <td>密码</td>
            </tr>
      </thead>
         <tbody>
         </tbody>

   </table>

</body>
</html>
